package View;

import java.awt.Component;
import java.awt.Dimension;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.ScrollPaneConstants;

import Model.Order;

@SuppressWarnings("serial")
public class CompletePanel extends JPanel {

	/**
	 * Create the panel.
	 */
	public CompletePanel(Component parent, Order order) {
		
		JTable orderText = order.createOrderTable();
		orderText.setCellSelectionEnabled(false);
		JScrollPane orderScrollPane = new JScrollPane(orderText, 
				 ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, 
				 ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);

		if(parent instanceof RestUWantGUI) {
			orderScrollPane.setPreferredSize(new Dimension(parent.getWidth() - 50, parent.getHeight() - 150));
		} else {
			orderScrollPane.setPreferredSize(new Dimension(parent.getWidth() - 30, parent.getHeight() - 100));
		}
		
		
		this.add(new JLabel(order.getTotalString()));
		
		add(orderScrollPane);
		
		if(parent instanceof RestUWantGUI) {
			((RestUWantGUI) parent).resetOrder();
			
		}
	}

}
